package pms.qa.action;

import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import pms.qa.service.QaNewService;
import pms.common.value.ProjectValue;
import pms.common.value.QaListValue;
import pms.common.value.QaNewValue;

import com.opensymphony.xwork2.ActionSupport;

public class QaNewAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private QaNewService qaNewService;
	public QaNewService getQaNewService() {
		return qaNewService;
	}

	public void setQaNewService(QaNewService qaNewService) {
		this.qaNewService = qaNewService;
	}
	private QaNewValue qaNew;
	private QaListValue qalist;
	private Collection<QaListValue> qalists;
	private String sysCD;
	private String sub_systemId;
	private static final int BUFFER_SIZE = 16 * 1024;
    private File myFile; 
	private String fileName; //myFileName
	
	
	public static int getBUFFER_SIZE() {
		return BUFFER_SIZE;
	}

	public String getFileName() {
		return fileName;
	}
	
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public void setMyFileFileName(String fileName) {
		this.fileName = fileName;
	}

	public File getMyFile() {
		return myFile;
	}

	public void setMyFile(File myFile) {
		this.myFile = myFile;
	}
	
	//プロジェクト
	public List<ProjectValue> getProjectList() {
		return qaNewService.getProjectList();
	}
	// 所属テーマ
	@SuppressWarnings("unchecked")
	public List<HashMap> getFunctionArray() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {   
        return qaNewService.getFunctionArray();
    }
	//発生箇所
	@SuppressWarnings("unchecked")
	public List<HashMap> getPartArray() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {   
        return qaNewService.getPartArray();
    }
	// 段階
	@SuppressWarnings("unchecked")
	public List<HashMap> getLevelArray() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {   
        return qaNewService.getLevelArray();
    }
	// 緊急度
	@SuppressWarnings("unchecked")
	public List<HashMap> getKinkyuuArray() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {   
        return qaNewService.getKinkyuuArray();
    }
	// 問合先
	@SuppressWarnings("unchecked")
	public List<HashMap> getAskedArray() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {   
        return qaNewService.getAskedArray();
    }
	

	@Override
	public String execute() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
		return SUCCESS;
	}
	
	public String insertData() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {

		System.out.println("file:"+ myFile);
		System.out.println("fileName:"+fileName);
		try {
			qaNewService.insertData(qaNew,myFile,fileName);
		}catch (Exception e) {
			e.printStackTrace();
		}
		qaNew = new QaNewValue();
		return SUCCESS;
	}
	
	public String returnList() {
		
		return SUCCESS;
	}
	
	public QaListValue getQalist() {
		return qalist;
	}
	public void setQalist(QaListValue qalist) {
		this.qalist = qalist;
	}
	public Collection<QaListValue> getQalists() {
		return qalists;
	}
	public void setQalists(Collection<QaListValue> qalists) {
		this.qalists = qalists;
	}

	
	@SuppressWarnings("unchecked")
	public List getMonthArray() {
		List l_list = new ArrayList();
		for (int i=0;i<12;i++) {
			if (i<9) {
				l_list.add(i,"0" + (i+1));
			} else {
				l_list.add(i,"" + (i+1));
			}
		}
		return l_list;		
	}
	
	@SuppressWarnings("unchecked")
	public List getDayArray() {
		List l_list = new ArrayList();
		for (int i=0;i<31;i++) {
			if (i<9) {
				l_list.add(i,"0" + (i+1));
			} else {
				l_list.add(i,"" + (i+1));
			}
		}
		return l_list;
	}

	public String getSysCD() {
		return sysCD;
	}
	public void setSysCD(String sysCD) {
		this.sysCD = sysCD;
	}
	public QaNewValue getQaNew() {
		return qaNew;
	}
	public void setQaNew(QaNewValue qaNew) {
		this.qaNew = qaNew;
	}
	public String getSub_systemId() {
		return sub_systemId;
	}
	public void setSub_systemId(String sub_systemId) {
		this.sub_systemId = sub_systemId;
	}

	
}